<template>
  <div id="app" :class="this.$store.state.fixflag?'fixed':''">
    <transition :name="transitionName">
      <router-view></router-view>
    </transition>
   
  </div>
</template>
<script>
import { getConfig, getwxAuthorizedloginUrl } from "@/api/filter";
import { GetUserInedx } from "@/api/user/index";
import cache from "@/utils/cache";
import Vue from 'vue';
import layer from 'vue-layer';
Vue.prototype.layer = layer(Vue);
export default {
  name: "app",
  data() {
    return {
      transitionName: "slide-fade"
    };
  },
  created() {
    this._appconfig();
     var cururl = window.location.href;
     if (cururl.indexOf("curuid=") == -1) {
        this._isLogin();
     }
  
    this._pageviews();
    //this._isLogin();
    document.body.removeChild(document.getElementById('Loading'))  
  },
  methods: {
    _appconfig() {
     

      //请求配置数据 存入仓库
      getConfig().then(res => {
        if (res.StatusCode === 200) {
          this.$store.state.filter_ZgzType = res.Data.ZgzType;
          this.$store.state.filter_ProStatu = res.Data.ProjectStatu;
          this.$store.state.filter_Role = res.Data.Role;
          this.$store.state.filter_Hyfl = res.Data.Hyfl;
          this.$store.state.filter_Area = res.Data.Area;
          this.$store.state.filter_JobNature = res.Data.JobNature;
          this.$store.state.filter_JobExperience = res.Data.JobExperience;
           this.$store.state.filter_LowSalary = res.Data.LowSalary;
        }
      });
    },
    //判断是否微信登陆 是不是微信浏览器
    _isWeiXin() {
      let ua = window.navigator.userAgent.toLowerCase();
      if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
      } else {
        return false;
      }
    },
    //判断是否登录
    _isLogin(){
        var user =cache.getLocal('zgz_user');
        var token =cache.getLocal('zgz_token');
        if(user==null||token==null){
            this.$router.push('/auth/login');
        }
        else{
        //  console.log(user);

          var js_user =JSON.parse(user);
     //     console.log(typeof(js_user["id"]));
        console.log(js_user.id);
this.$store.state.userinfo=js_user;
           this.$store.state.token=token;
        }
    },
     _pageviews() {
      //分享出去的地址 其他人点击地址之后须记录浏览量
      var cururl = window.location.href;
      if (cururl.indexOf("curuid=") != -1) {
           //分享出去之后的页面 别人点击进来时需记录 其归属关系
          var curuid=_getQueryPara("curuid");
          delCookie("zgz_fx_pid");
          addCookie("zgz_fx_pid", curuid, 72);
      }
    },
  },
  watch: {
    $route(to, from) {
      const toDepth = to.path.split("/").length;
      const fromDepth = from.path.split("/").length;
      this.transitionName = toDepth < fromDepth ? "slide-right" : "slide-left";
    }
  }
};
</script>
<style lang="scss" >
body {
  background: #f4f4f4;
}
.fixed{
  position: fixed;
  left:0;
  right: 0;
}
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  background: #ffffff;
}
.no-text {
  p{
    text-align: center;
    padding: 10px 0 10px 0;
 }
}
// .slide-fade-enter-active {
//   transition: all .3s ease;
// }
// .slide-fade-leave-active {
//   transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
// }
// .slide-fade-enter, .slide-fade-leave-active {
//   padding-left: 10px;
//   opacity: 0;
// }
</style>
